﻿@model CustomerOrderListModel
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Account").Text);
}
@using Nop.Web.Models.Customer
@using Nop.Web.Models.Order;
@section left
{
    @Html.Action("CustomerNavigation", "Customer", new { selectedTabId = CustomerNavigationEnum.Orders })
}
<div class="panel panel-default form-panel">
    <div class="panel-heading">
        <h3>@T("Account.MyAccount") - @T("Account.CustomerOrders")</h3>
    </div>
    <div class="panel-body">
        @if (Model.RecurringOrders.Count > 0)
        {
            using (Html.BeginForm())
            {
                <div class="section recurring-payments">
                    <div class="title">
                        <strong>@T("Account.CustomerOrders.RecurringOrders")</strong>
                    </div>
                    <div class="recurring-payments-box">
                        <table class="data-table">
                            <colgroup>
                                <col />
                                <col />
                                <col />
                                <col />
                                <col />
                                <col />
                                <col />
                            </colgroup>
                            <thead>
                                <tr>
                                    <th class="a-center start-date">
                                        @T("Account.CustomerOrders.RecurringOrders.StartDate")
                                    </th>
                                    <th class="a-center cycle-info">
                                        @T("Account.CustomerOrders.RecurringOrders.CycleInfo")
                                    </th>
                                    <th class="a-center next-payment">
                                        @T("Account.CustomerOrders.RecurringOrders.NextPayment")
                                    </th>
                                    <th class="a-center total-cycles">
                                        @T("Account.CustomerOrders.RecurringOrders.TotalCycles")
                                    </th>
                                    <th class="a-center cycles-remaining">
                                        @T("Account.CustomerOrders.RecurringOrders.CyclesRemaining")
                                    </th>
                                    <th class="a-center initial-order">
                                        @T("Account.CustomerOrders.RecurringOrders.InitialOrder")
                                    </th>
                                    <th class="a-center cancel">
                                        @T("Account.CustomerOrders.RecurringOrders.Cancel")
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach (var item in Model.RecurringOrders)
                                {
                                    <tr>
                                        <td class="a-center start-date">
                                            @item.StartDate
                                        </td>
                                        <td class="a-center cycle-info">
                                            @item.CycleInfo
                                        </td>
                                        <td class="a-center next-payment">
                                            @item.NextPayment
                                        </td>
                                        <td class="a-center total-cycles">
                                            @item.TotalCycles
                                        </td>
                                        <td class="a-center cycles-remaining">
                                            @item.CyclesRemaining
                                        </td>
                                        <td class="a-center initial-order">
                                            <a href="@Url.RouteUrl("OrderDetails", new { orderId = item.InitialOrderId })">@string.Format(T("Account.CustomerOrders.RecurringOrders.ViewInitialOrder").Text, item.InitialOrderId)</a>
                                        </td>
                                        <td class="a-center cancel">
                                            @if (item.CanCancel)
                                            {
                                                <input type="submit" name="cancelRecurringPayment@(item.Id)" value="@T("Account.CustomerOrders.RecurringOrders.Cancel")" class="btn btn-default btn-xs" />
                                            }
                                        </td>
                                    </tr>
                                }
                            </tbody>
                        </table>
                    </div>
                </div>
            }
            if (Model.CancelRecurringPaymentErrors.Count > 0)
            {
                <div class="message-error">
                    <ul>
                        @foreach (var error in Model.CancelRecurringPaymentErrors)
                        {
                            <li>@error</li>
                        }
                    </ul>
                </div>
            }
        }
        <div class="order-list">
            @if (Model.Orders.Count > 0)
            {
                foreach (var order in Model.Orders)
                {
                    <div class="section order-item">
                        <div class="title">
                            <strong>@T("Account.CustomerOrders.OrderNumber"): @order.Id</strong>
                        </div>
                        <ul class="info">
                            <li>@T("Account.CustomerOrders.OrderStatus"): <span class="order-status @order.OrderStatusEnum.ToString().ToLowerInvariant()">@order.OrderStatus</span></li>
                            <li>@T("Account.CustomerOrders.OrderDate"): <span class="order-date">@order.CreatedOn.ToString()</span></li>
                            <li>@T("Account.CustomerOrders.OrderTotal"): <span class="order-total">@order.OrderTotal</span></li>
                        </ul>
                        <div class="buttons">
                            @if (order.IsReturnRequestAllowed)
                            {
                                <input type="button" value="@T("Account.CustomerOrders.ReturnItems")" class="btn btn-default btn-xs" onclick="setLocation('@Url.RouteUrl("ReturnRequest", new { orderId = order.Id })')" />
                            }
                            <input type="button" value="@T("Account.CustomerOrders.OrderDetails")" class="btn btn-default btn-xs" onclick="setLocation('@Url.RouteUrl("OrderDetails", new { orderId = order.Id })')" />
                        </div>
                    </div>
                <hr />
                }
            }
            else
            {
                @T("Account.CustomerOrders.NoOrders")
            }
        </div>
    </div>
</div>
